import request from '@/utils/request'
import { reviseParam } from '@/utils/util'

const mgr = './mgr'
const url = {
  ORG_LIST: `${mgr}/WeBASE-Node-Manager`
}

/**
 * 获取节点列表
 * @param {*} params
 * @returns
 */
export function node_list(params) {
  return request({
    url: '/node',
    method: 'get',
    params
  })
}

export function getNodeList(data, list) {
  const params = reviseParam(data, list)
  return request({
    baseURL: process.env.VUE_APP_IS_PROXY === '1' ? '' : process.env.VUE_APP_MGR_URL,
    url: `${url.ORG_LIST}/node/nodeList/${params.str}`,
    method: 'get',
    params: params.querys,
    headers: {
      AuthorizationToken: 'Token ' + localStorage.getItem('token') || ''
    }
  })
}

export function getConsensusNodeId(data) {
  return request({
    baseURL: process.env.VUE_APP_IS_PROXY === '1' ? '' : process.env.VUE_APP_MGR_URL,
    url: `${url.ORG_LIST}/precompiled/consensus/list`,
    method: 'get',
    params: data,
    headers: {
      AuthorizationToken: 'Token ' + localStorage.getItem('token') || ''
    }
  })
}
